package util

import (
	"github.com/gin-gonic/gin"
)

type MyJson struct {
	Code    int         `json:"code"`
	Msg     string      `json:"msg"`
	Content interface{} `json:"content"`
}

func ReturnJson(ctx *gin.Context, code int, err error, data interface{}) {
	msg := ReturnErr(code)
	if err != nil {
		msg += " error is : " + err.Error()
	}
	res := &MyJson{
		Code:    code,
		Msg:     msg,
		Content: data,
	}
	ctx.JSONP(ReturnHeaderCode(code), res)
}
